#
# Python test scanner plugin

from sys import argv, exit
import re

def scanfile(infile):
	#
	# regex matches any lien that starts with "#if" and a decimal carcher ("#if 0" and "#if 1" etc.)
	# understands C++ whitespace rules as well.
	#
	regex = r"""^\s*#\s*if\s* \d"""
	compiled_regex = re.compile(regex)

	f = open(infile, "r")
	lineNumber = 0;
	for line in f:
		lineNumber += 1
		match_obj = compiled_regex.search(line)
		if (match_obj is not None):
			print "%s|%d" % (infile, lineNumber)

if __name__ == "__main__":
	if "--name" in argv:
		print "hashifzero"
		exit(0)
	if "--explain" in argv:
		print '''Will report lines of code excluded from compilation using the "#if 0" preprocessor directive.'''
		exit(0)
	if "--lc" in argv:
		exit(0) # don't need any configuration!
	if "--inputFile" in argv:
		infile = argv[argv.index("--inputFile") + 1]
		scanfile(infile)
